abstract class Student {
    private String name;
    private int age;
    private String grad;

    public Student(String name, int age, String grad) {
        this.name = name;
        this.age = age;
        this.grad = grad;
    }

    public abstract void study();

    public abstract void eat();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGrad() {
        return grad;
    }

    public void setGrad(String grad) {
        this.grad = grad;
    }
}

class undergraduate extends Student {

    public undergraduate(String name, int age, String grad) {
        super(name, age, grad);
    }

    @Override
    public void study() {
        System.out.println("本科生：" + super.getName() + "正在学习");
    }

    @Override
    public void eat() {
        System.out.println("本科生：" + super.getName() + "正在吃饭");
    }
}

class postgraduate extends Student {

    public postgraduate(String name, int age, String grad) {
        super(name, age, grad);
    }

    @Override
    public void study() {
        System.out.println("研究生：" + super.getName() + "正在学习");
    }

    @Override
    public void eat() {
        System.out.println("研究生：" + super.getName() + "正在吃饭");
    }
}

public class StudentDemo {
    public static void main(String[] args) {
        Student student1 = new undergraduate("张三",20,"计算机23级2班");

        Student student2 = new postgraduate("李四",26,"电气工程24级1班");

        System.out.println("进行属性的访问：");
        System.out.println("姓名:" + student1.getName());
        System.out.println("年龄:" + student1.getAge());
        System.out.println("班级:" + student1.getGrad());
        System.out.println();
        System.out.println("姓名:" + student2.getName());
        System.out.println("年龄:" + student2.getAge());
        System.out.println("班级:" + student2.getGrad());

        System.out.println();

        System.out.println("进行方法的访问：");
        student1.study();
        student1.eat();

        System.out.println();
        student2.study();
        student2.eat();
    }
}
